<?php

namespace Database\Seeders;

use App\Models\Tenant;
use Illuminate\Database\Seeder;

class TenantSeeder extends Seeder
{
    public function run(): void
    {
        if (Tenant::count() > 0) {
            $this->command?->info('TenantSeeder: 已存在租户数据，跳过创建。');
            return;
        }

        $tenant = Tenant::create([
            'name' => '测试租户',
            'company_name' => '测试租户有限公司',
            'tax_registration_number' => '91330000TEST0001',
            'address' => '浙江省杭州市西湖区古墩路888号',
            'bank_name' => '中国银行杭州分行',
            'bank_account' => '6222020200001234567',
            'invoice_contact_phone' => '13800138000',
            'invoice_mailing_address' => '浙江省杭州市西湖区古墩路888号开票中心',
            'invoice_recipient' => '张三',
            'contact_phone' => '13800138000',
            'contact_email' => 'tenant@example.com',
            'tenant_type' => Tenant::TYPE_ENTERPRISE,
            'service_fee_rate' => 0.05,
            'status' => Tenant::STATUS_ACTIVE,
            'account_balance' => 0,
            'invoiceable_amount' => 0,
        ]);

        $this->command?->info(sprintf('TenantSeeder: 已创建默认租户 %s (ID: %s)。', $tenant->name, $tenant->id));
    }
}
